package NQueen;

public class Queen {
    private int row;
    private int col;

    public Queen(int row, int col) {
        if (row < 0 || col < 0) {
            throw new IllegalArgumentException("行和列不能为负数");
        }
        this.row = row;
        this.col = col;
    }

    public int getRow() {
        return row;
    }

    public int getCol() {
        return col;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        Queen queen = (Queen) obj;
        return row == queen.row && col == queen.col;
    }

    @Override
    public int hashCode() {
        return 31 * row + col;
    }

    @Override
    public String toString() {
        return "Queen{row=" + row + ", col=" + col + "}";
    }
}